package com.yorick;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "DirectQueue")
class DirectQueueClient {
    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println(jsonObject.toJSONString());
    }
}


@Component
@RabbitListener(queues = "topic.first")
class TopicQueueClient {

    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println(jsonObject.toJSONString());
    }
}

@Component
@RabbitListener(queues = "topic.second")
class TopicQueueClient2 {

    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println(jsonObject.toJSONString());
    }
}

@Component
@RabbitListener(queues = "fanout.A")
class FanoutQueueClientA {

    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println("fanoutA recevied:= "+jsonObject.toJSONString());
    }
}

@Component
@RabbitListener(queues = "fanout.B")
class FanoutQueueClientB {

    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println("fanoutB recevied:= "+jsonObject.toJSONString());
    }
}

@Component
@RabbitListener(queues = "fanout.C")
class FanoutQueueClientC {

    @RabbitHandler
    void handler(JSONObject jsonObject){
        System.out.println("fanoutC recevied:= "+jsonObject.toJSONString());
    }
}